;; This shows how the good-enough? procedure will fail with very small and
;; very big numbers

(define (sqrt-iter guess x)
   (if (good-enough? guess x)
       guess
       (sqrt-iter (improve guess x)
                  x)))

(define (square x) (* x x))

(define (improve guess x)
   (average guess (/ x guess)))
 

(define (average x y)
   (/ (+ x y) 2))
 
(define (good-enough? guess x)
   (< (abs (- (square guess) x)) 0.001))
 
(define (my-sqrt x)
   (sqrt-iter 1.0 x))

;; that prints 0.00162414018569925 in my computer
(square (my-sqrt 0.0009))


;; that never finishes (improve returns the same number again
;; and again, but squaring it is not close to the desired value
;; (not whithin the 0.001 margin).
(square (my-sqrt 1e50))
